-- card: 10225 from stack: in.3 -- bmap block id: 0 -- flags: 0000 -- background id: 2663 -- name: -- part 1 (button) -- low flags: 00 -- high flags: A004 -- rect: left=287 top=33 right=70 bottom=447 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Easy Text Import ----- HyperTalk script ----- on copyright -- Easy Text Import, Copyright by Mac Help Co., January 1988 -- by Chris Hostetter, Mac Help Co., 1800 East Market Street -- Long Beach, CA 90805, (213) 428-7414 -- The script for this button is copyrighted and may not be -- used without the written permission of the author (above). end copyright on mouseUp Global THISDATA, ThisFile ask "The TEXT file and this STACK program must be in the same" && "folder or on the same level!" & Return & Return & "Name of the TEXT file to import?" with ThisFile if it is empty then exit mouseUp put it into ThisFile open file ThisFile put true into SkipLines put true into FirstImport put 1 into ShowEveryFew put 10 into WhenToShow put 0 into NxtLn put empty into PutDataHere answer "Read data into a VARIABLE, an EXISTING field, or a NEW field?" with "Variable" or "Existing" or "New" if it is "Variable" then answer "Data will be READ into the Global Variable: 'THISDATA'" put quote & "THISDATA" & quote into PutDataHere else if it is "Existing" then if the number of background fields is 0 and the number of card fields is 0 then answer "Put Data into a Field or Variable?" with "Variable" end if if the number of background fields > 0 and the number of card fields is 0 then answer "Put Data into a Field or Variable?" with "Background" or "Variable" end if if the number of background fields is 0 and the number of card fields > 0 then answer "Put Data into a Field or Variable?" with "Card" or "Variable" end if if the number of background fields > 0 and the number of card fields > 0 then answer "Put Data into a Field or Variable?" with "Background" or "Card" or "Variable" end if if it is "Background" then repeat with i = 1 to the number of background fields ask "Read DATA into Bkgnd Field" && i && "of" && the number of Bkgnd fields with the name of background field i if it is not empty then put it into PutDataHere exit repeat end if end repeat end if if it is "Card" then repeat with i = 1 to the number of card fields ask "Read DATA into Card Field" && i && "of" && the number of card fields with the name of card field i if it is not empty then put it into PutDataHere exit repeat end if end repeat end if else set lockscreen to true -- CREATE A NEW FIELD, BUT CHECK IT OUT put the userlevel into OldUserLevel set userlevel to 5 set lockscreen to true put the number of card fields into TotalFields doMenu "New Field" put the number of card fields into NewTotalFields set the userlevel to OldUserLevel if TotalFields is NewTotalFields then answer "Couldn't creat a field, data will be READ into the Global Variable: THISDATA" put quote & "THISDATA" & quote into PutDataHere else set the name of card field NewTotalFields to "This Data" set the style of card field NewTotalFields to "Scrolling" set the textfont of card field NewTotalFields to "Monaco" set the textSize of card field NewTotalFields to 9 choose browse tool set the rect of card field NewTotalFields to 4,69,508,290 put "Card field" && quote & "This Data" & quote into PutDataHere set lockscreen to false set lockscreen to false end if end if end if if PutDataHere is empty then beep answer "No field selected! You might want to try 'NEW' to" && "automatically create a new field for you!" close file ThisFile exit mouseUp end if --ask "This is the selected location" with PutDataHere if PutDataHere contains "Field" then do "set the style of" && PutDataHere && "to Scrolling" do "get the rect of" && PutDataHere put item 4 of it - item 2 of it into PageFull put the round of (PageFull - (PageFull/2)) into PageFull put 0 into ThisScroll end if set cursor to 4 repeat forever read from file ThisFile until return put it into ThisLine if SkipLines is true then repeat forever --put char 1 to 36 of it into it --put "..." after it if it is empty then put "*** NO DATA FOUND *** Hit the SKIP" && "LINE button, or CANCEL and re-check the name of the" && "data file!" into it add 1 to Nxtln answer "Begin IMPORT at line" && NxtLn && "or skip this line?" && Return & Return & it with CANCEL or "Skip Line" or "Do IMPORT" if it is "Cancel" then close file ThisFile exit mouseUp end if if it is "Skip Line" then read from file ThisFile until return put it into ThisLine else put false into SkipLines set lockscreen to true exit repeat end if if ThisLine is empty then close file ThisFile exit mouseUp end if end repeat end if if ThisLine is empty then exit repeat do "put ThisLine after" && PutDataHere add 1 to Nxtln set cursor to 4 -- LOCK & UNLOCK SCREEN TO SHOW STATUS EVERY SO OFTEN add 1 to ShowEveryFew if PutDataHere contains "field" then if the value of ShowEveryFew ≥ WhenToShow then set lockscreen to false put 0 into ShowEveryFew set lockscreen to true add PageFull to ThisScroll do "set the scroll of" && PutDataHere && "to ThisScroll" end if end if end repeat close file ThisFile end mouseUp -- part 20 (field) -- low flags: 00 -- high flags: 0007 -- rect: left=269 top=76 right=290 bottom=506 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 4 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: Scrolling Field -- part contents for background part 8 ----- text ----- Card 7 of 20 -- part contents for background part 9 ----- text ----- EASY TEXT IMPORT This button will import a text file. It will ask if you want to import the text file three different ways: 1. To a global variable (for use later) 2. To an existing field, it will check to see if you have any existing background and/or card fields on the current card, and if any exist, it will let you select which one you want to use. 3. And finally, you can select NEW in which case it will make a new scrolling card field and it will read the data right into that field.